﻿<?php

/* TravelTaste(C) 2009 - 2010
  *$ 22:35 2010-4-11
  * friend.php
 * Author: Yuhuang@ncic.ac.cn
*/


 
// 初始化页面
require_once "./init.php";
require_once "./sim.php";

$action = getgpc("action");
$view_uid = getgpc("uid");
/* 强制让用户登录 */
if(1)
if (true != check_user_login("raywill", "111111"))
{
	die("wrong user/pass");
}

/* 登录用户 */

if (isset($_SESSION['login']) && $_SESSION['login']== true)
{
	/* 到达这一步的时候，可以确定系统已经取得了登录用户的基本信息*/
	$uid = $_SESSION['user']['uid'];
	//echo $_SESSION['user']['user'];
	$info = null;
	$state_list = null;
	$desc_list = null;
	$friend_list = null;
	switch($action)
	{
	default:
		/* fall through */
	case "basic":	/* 基本信息管理 */
		$basic_user_info = $_SGLOBAL['db']->fetch_all("SELECT * FROM ".TT_DBTABLEPRE."user as t1 WHERE "
		."t1.uid=$view_uid LIMIT 1");
	
		$state_list = $_SGLOBAL['db']->fetch_all("SELECT * FROM ".TT_DBTABLEPRE."state_list as t1 WHERE "
		."t1.uid=$view_uid and t1.state_type=1 ORDER BY t1.post_date LIMIT 100");
		
		$desc_list = $_SGLOBAL['db']->fetch_all("SELECT * FROM ".TT_DBTABLEPRE."friend_description as t1 WHERE "
		."t1.reply_to_uid=$view_uid ORDER BY t1.desc_time LIMIT 100");

		// 最近访客
		$recent_visitor = $_SGLOBAL['db']->fetch_all("SELECT * FROM ".TT_DBTABLEPRE."recent_visitor WHERE host_id = $view_uid ORDER BY visit_time  DESC LIMIT 9");
		
		// 好友列表
		$friend_list =  $_SGLOBAL['db']->fetch_all("SELECT * FROM ".TT_DBTABLEPRE."friend_list WHERE host_id = $view_uid ORDER BY become_friend_time LIMIT 9");
		
		$info = array(
			"action" => "basic",
			//"action" => $action,
			"basic_user_info" => $basic_user_info,
			"state_list" => $state_list,
			"friend_desc" => $desc_list,
			"recent_visitor" => $recent_visitor,
			"friend_list" => $friend_list,
			"user_info" => $_SESSION['user'],
			"session" => $_SESSION
		);		
		break;
	}
	
	//var_dump($info);
	
	$_SGLOBAL['view']->assign('image_root', TT_ROOT.'./images/icon');
	$_SGLOBAL['view']->assign("info",$info);
	$_SGLOBAL['view']->display('friend_std.tpl');

}
/* 未登录用户 */
else
{

	die("Please login to view profile.php page ");

}



function display_login_page($get)
{
	global $_SGLOBAL;
	// 显示页面

}

/*
 * 获得guest用户的目标旅行位置
 */
function determin_guest_distination()
{
	

	/* 先尝试从SESSION中获取用户选择的位置 
	 * 获取失败，则设置为空 
	 */
	if (isset($_SESSION['distination_setting']))
	{
		$d = getgpc("distination");
		if (null != $d)	/*设置了新的地址, 则更新session */
		{
			$_SESSION['distination_setting'] = $d;
		}
		return $_SESSION['distination_setting'];
	}
	else
	{
		/* 尝试读取用户输入，看是否在本次设置位置 */
		$d = getgpc("distination"); /*设置了地址, 保存进session */
		if (null != $d)
		{
			$_SESSION['distination_setting'] = $d;
			return $_SESSION['distination_setting'];
		}
		return null;
	}
}

function determin_guest_location()
{
	if (isset($_SESSION['location_setting']))
	{
		$d = getgpc("location");
		if (null != $d)
		{
			$_SESSION['location_setting'] = $d;
		}
		return $_SESSION['location_setting'];
	}
	else
	{
		/* 尝试读取用户输入，看是否在本次设置位置 */
		$d = getgpc("location");
		if (null != $d)
		{
			$_SESSION['location_setting'] = $d;
			return $_SESSION['location_setting'];
		}
	}
	return null;
}


?>









